import {BasicColumn} from '/@/components/Table';
import {FormSchema} from '/@/components/Table';
import { rules} from '/@/utils/helper/validator';
import { render } from '/@/utils/common/renderUtils';
//列表数据
export const columns: BasicColumn[] = [
  {
    title: '计划名称',
    align: "center",
    dataIndex: 'planName'
  },
  {
    title: '是否开启',
    align: "center",
    dataIndex: 'isEnable',
    slots: { customRender: 'switch' },
  },
  {
    title: '平台',
    align: "center",
    dataIndex: 'platform_dictText',
    width:250,
  },
  {
    title: '内容类型',
    align: "center",
    dataIndex: 'contentType',
    customRender:({text}) =>{
      return text===1?'小说':'H5页面'
    },
  },
  {
    title: '内容',
    align: "center",
    dataIndex: 'content',
    width:250,
  },
  {
    title: '图片',
    align: "center",
    dataIndex: 'img',
    customRender: render.renderImage,
  },
  {
    title: '有效日期',
    align: "center",
    dataIndex: 'endTime',
    width:250,
    customRender:({record}) =>{
      return record.startTime+'至'+record.endTime
    },
  },
  {
    title: '触发方式',
    align: "center",
    dataIndex: 'triggerType',
    customRender:({text}) =>{
      return text===1?'冷启动首页':''
    },
  },
  {
    title: '展示频率',
    align: "center",
    dataIndex: 'frequencyCount',
    width:250,
    customRender:({record}) =>{
      let str=''
      if (record.frequencyType===-1){
        str='不限制'
      }else {
        let dayStr=''
        if (record.frequencyType===1){
          dayStr='天'
        }else if (record.frequencyType===7){
          dayStr='周'
        }else if (record.frequencyType===30){
          dayStr='月'
        }
        str=`每${record.frequencyInterval}${dayStr}展示${record.frequencyCount}次`
      }
      return str
    },
  },
  {
    title: '创建时间',
    align: "center",
    dataIndex: 'createTime'
  },

];

//查询数据
export const searchFormSchema: FormSchema[] = [
];

//表单数据
export const formSchema: FormSchema[] = [
  {
    label: '计划名称',
    field: 'planName',
    component: 'Input',
  },
  {
    label: '平台 对应字典platform',
    field: 'platform',
    component: 'JDictSelectTag',
    componentProps:{
      dictCode: ""
    },
  },
  {
    label: '1=小说 2=H5页面',
    field: 'contentType',
    component: 'JDictSelectTag',
    componentProps:{
      dictCode: ""
    },
  },
  {
    label: '小说的话为ID H5为链接地址',
    field: 'content',
    component: 'Input',
  },
  {
    label: '图片地址',
    field: 'img',
    component: 'JImageUpload',
    componentProps:{
    },
  },
  {
    label: '有效日期开始时间',
    field: 'startTime',
    component: 'DatePicker',
  },
  {
    label: '有效日期截止时间',
    field: 'endTime',
    component: 'DatePicker',
  },
  {
    label: '触发方式 1=冷启动首页 目前只有这个',
    field: 'triggerType',
    component: 'JDictSelectTag',
    componentProps:{
      dictCode: ""
    },
  },
  {
    label: '展示类型 -1=无限制 1=天 7=周 30=月',
    field: 'frequencyType',
    component: 'JDictSelectTag',
    componentProps:{
      dictCode: ""
    },
  },
  {
    label: '展示间隔',
    field: 'frequencyInterval',
    component: 'InputNumber',
  },
  {
    label: '展示频次',
    field: 'frequencyCount',
    component: 'InputNumber',
  },
  {
    label: '是否开启',
    field: 'isEnable',
    component: 'JSwitch',
    componentProps:{
    },
  },
	// TODO 主键隐藏字段，目前写死为ID
  {
    label: '',
    field: 'id',
    component: 'Input',
    show: false,
  },
];
